package com.jt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jt.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
//@Mapper//为接口创建一个反射机制的一个对象
//MP规则：BaseMapper<T> T MP要操作的是谁，T必须引入对象
public interface UserMapper extends BaseMapper<User> {
    List<User>  findAll();
    @Insert("insert into demo_user(id,name,age,sex)value(null,#{name},#{age},#{sex})")
    void insertUser(User user);
    @Update("update demo_user set name = #{newName} where name = #{oldName}")
    void updateByName(String oldName, String newName);
//    mybatis 中如果传递的参数只有一个，则名称任意写，一般不用
    @Delete("delete from demo_user where name=#{name}")
    void deleteByName(String name);
    List<User> findId(Integer id);
    List<User> findNameSex(String name,String sex);
    List<User> findAgeSex(Integer age,String sex);
    List<User> contain(String string);
    List<User> findIn(List id );
    List<User> findNull(String name);
    List<User> findAgeOrSex(Integer age,String sex);
    List<User> findNameAge();
    List<User> findNameAgeOnly();
}
